//
//  ReloadMenuTableViewCell1.m
//  MKUI
//
//  Created by 苏尚进 on 2020/11/10.
//Copyright © 2020 moon. All rights reserved.
//

#import "ReloadMenuTableViewCell1.h"

@interface ReloadMenuTableViewCell1 ()

@end

@implementation ReloadMenuTableViewCell1
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
	if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.menuButton = [[MKUIFlowLayoutButton alloc] init];
        self.menuButton.imageSize = CGSizeMake(40, 40);
        self.menuButton.titleLabel.numberOfLines = 0;
        self.menuButton.interitemSpacing = 15;
        [self.menuButton setTitleColor:[UIColor systemBlueColor] forState:UIControlStateNormal];
        self.menuButton.contentInsets = MKUIEdgeInsetsMakeSameEdge(5);
        [self.contentView addSubview:self.menuButton];
	}
	return self;
}
- (void)customLayoutSubviews{
	[super customLayoutSubviews];
	CGRect bounds = self.contentView.bounds;
    self.menuButton.frame = bounds;
}
- (void)customReloadCellModel{
    [super customReloadCellModel];
	Menu *modelValue = self.cellModel.modelValue;
    [self.menuButton setTitle:modelValue.title forState:UIControlStateNormal];
    [self.menuButton setImage:modelValue.icon forState:UIControlStateNormal];
    self.menuButton.contentStyle = [self.cellModel mk_integerForKeyPath:@"contentStyle" otherwise:MKUIFlowLayoutButtonContentStyleHorizontal];
}
//- (void)tableView:(UITableView *)tableView willDisplayCellModel:(__kindof MKUITableViewCellModel *)cellModel{
//    
//}
//- (void)tableView:(UITableView *)tableView didEndDisplayingCellModel:(__kindof MKUITableViewCellModel *)cellModel{
//
//}

- (CGSize)customSizeThatFits:(CGSize)size{
	return [self.menuButton sizeThatFits:size];
}
//MKDEF_SINGLETON(ReloadMenuTableViewCell1)
//+ (CGFloat)estimatedHeightWithTableView:(UITableView *)tableView cellModel:(__kindof MKUITableViewCellModel *)cellModel{
//    NSLog(@"estimatedHeight:%@",cellModel.indexPathInModel);
//    return 50;
//    return [self dynamicHeightWithTableView:tableView cellModel:cellModel cellShareInstance:[self sharedInstance] calBlock:^CGFloat(UITableView * _Nonnull tableView, MKUITableViewCellModel * _Nonnull cellModel, ReloadMenuTableViewCell1 *  _Nonnull cell) {
//        return [cell sizeThatFits:CGSizeMake(tableView.bounds.size.width, 99999999)].height;
//    }];
//}
//+ (CGFloat)heightWithTableView:(UITableView *)tableView cellModel:(__kindof MKUITableViewCellModel *)cellModel{
////    NSLog(@"Height:%@",cellModel.indexPathInModel);
//    return 50;
//    return [self dynamicHeightWithTableView:tableView cellModel:cellModel cellShareInstance:[self sharedInstance] calBlock:^CGFloat(UITableView * _Nonnull tableView, MKUITableViewCellModel * _Nonnull cellModel, ReloadMenuTableViewCell1 *  _Nonnull cell) {
//        return [cell sizeThatFits:CGSizeMake(tableView.bounds.size.width, 99999999)].height;
//    }];
//}
@end
